import request from '@/utils/request'

export function login(username, password) {
  return request({
    url: 'umc/login/in?username='+username+'&password='+password,
    method: 'get',
  })
}

export function getInfo() {
  return request({
    url: 'partner/user/getCurrentLoginUserPermission',
    method: 'POST',
  })
}

export function getMenus(roleCode) {
  return request({
    url: 'partner/role/menus/'+roleCode,
    method: 'GET',
  })
}


export function logout() {
  return request({
    url: '/umc/login/out',
    method: 'GET'
  })
}

export function fetchList(params) {
  return request({
    url: '/product/user/query/'+params.pageNum+'/'+params.pageSize,
    method: 'post',
    data: params
  })
}

export function createUser(data) {
  return request({
    url: '/partner/user/add',
    method: 'post',
    data: data
  })
}

export function updateAdmin(id, data) {
  return request({
    url: '/admin/update/' + id,
    method: 'post',
    data: data
  })
}

export function updateStatus(id, params) {
  return request({
    url: '/partner/user/updateStatus/' + id,
    method: 'post',
    params: params
  })
}

export function deleteAdmin(id) {
  return request({
    url: '/admin/delete/' + id,
    method: 'post'
  })
}

export function getRoleByUserId(id) {
  return request({
    url: '/partner/user/queryUserRoleDetail/' + id,
    method: 'post'
  })
}

export function allocRole(data) {
  return request({
    url: '/partner/user/role/saveOrupdate',
    method: 'post',
    data: data
  })
}
